import Vue from "vue";
import Router from "vue-router";
Vue.use(Router);

import layout from '@/layout'
import home from '@/views/home'
import search from '@/views/search'
import order from '@/views/order'
import profile from '@/views/profile'
import shopClass from '@/views/home/components/shopClass'
import address from '@/views/address'
import mapList from '@/views/address/components/mapList'
import searchAddress from '@/views/address/components/searchAddress'
import info from "@/views/profile/info.vue";
import setusername from "@/views/profile/setusername.vue";
import profileaddress from "@/views/profile/address.vue";
import add from "@/views/profile/add.vue";
import addDetail from "@/views/profile/addDetail.vue";




const routes = [


    {
        path: '/',
        component: layout,
        redirect: '/home',
        children: [
            //  外卖页
            { path: '/home', component: home, name: "home" },
            //  搜索
            { path: '/search', component: search, name: "search" },
            //  订单
            { path: '/order', component: order, name: "order" },
            //  我的
            //  我的
            {
                path: '/profile', component: profile, name: "profile",
            },
        ]
    },
    { path: '/discounts', name: 'discounts', component: () => import('@/views/profile/discounts/index') },
    { path: '/myBalance', component: () => import('@/views/profile/components/myBalance') },
    { path: '/myBalance/detail', component: () => import('@/views/profile/components/detail') },
    { path: '/integral', component: () => import('@/views/profile/components/integral') },
    { path: '/integral/points', component: () => import('@/views/profile/components/points') },
    // 购物详情页
    { path: '/shop/:id', component: () => import('@/views/shop') },
    //  编辑个人信息
    { path: "/profile/info", component: info },
    //  更新用户名
    { path: "/profile/info/setusername", component: setusername },
    //  编辑地址
    { path: "/profile/info/address", component: profileaddress },
    //  新增地址
    { path: "/profile/info/add", component: add, name: "addAll", meta: { keepAlive: true } },
    //  新增地址详情
    { path: "/profile/info/add/addDetail", component: addDetail },

    { path: '/home/:parmas', component: shopClass, name: 'shopClass' },
    { path: '/address', component: address },
    { path: '/mapList', component: mapList },
    { path: '/address/search', component: searchAddress },
    {
        path: '/login',
        component: () => import('@/views/login/index'),
    },
    {
        path: '/forget',
        component: () => import('@/views/forget/index'),
    },
    {
        path: '/vipcard',
        component: () => import('@/views/vipcard/index'),
    },
    {
        path: '/vipcard/vipDescription',
        component: () => import('@/views/vipDescription/index'),
    },
    {
        path: '/confirmOrder/payment',
        component: () => import('@/views/payment/index'),
    },
    {
        path: '/vipcard/useCart',
        component: () => import('@/views/usecart/index'),
    },
    //服务中心
    {
        path: '/service',
        component: () => import('@/views/service/index'),
        children: [{
            path: 'questionDetail', //订单详情页
            component: () => import('@/views/questionDetail/index'),
        },]
    },  // 订单结算
    { path: '/confirmOrder', component: () => import('@/views/confirmOrder') },
    // 选择地址
    {
        path: '/confirmOrder/chooseAddress',
        component: () => import('@/views/confirmOrder/chooseAddress')
    },
    // 订单备注
    {
        path: '/confirmOrder/remark',
        component: () => import('@/views/confirmOrder/remark')
    },
    // 订单发票
    {
        path: '/confirmOrder/invoice',
        component: () => import('@/views/confirmOrder/invoice')
    },
    {
        path: '/shopDetail',
        component: () => import('@/views/shopDetail/index'),
    },
]

export const router = new Router({
    routes
})

